package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.api.RemoteMessageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 消息服务降级处理
 * 
 * @author ruoyi
 */
@Component
public class RemoteMessageFallbackFactory implements FallbackFactory<RemoteMessageService>
{
    private static final Logger log = LoggerFactory.getLogger(RemoteMessageFallbackFactory.class);

    @Override
    public RemoteMessageService create(Throwable throwable)
    {
        log.error("消息服务调用失败:{}", throwable.getMessage());
        return new RemoteMessageService()
        {
            @Override
            public R activitiReminderMessage(Integer hour) {
                return R.fail("发送所有需要被提醒的用户和角色消息失败:" + throwable.getMessage());
            }
        };
    }
}
